<?php

namespace PcHome\Controller;
use Common\Controller\PcHomeBaseController;
class OnePageController extends PcHomeBaseController {
    /*
     * 单页面
     * */
    const DEFAULT_TEMPLATE = 'page';
    public function index() {
        $article_id = I('get.article_id',0,'intval');
        $article = x_sql_one_page($article_id);

        if(empty($content)){
            $this->error('文章不存在或已经被删除!');
        }

        $this->assign($article);
        $addition = json_decode($article['addition'], true);
        $tplname = empty($addition['template']) ?
            self::DEFAULT_TEMPLATE : $addition['template'];
        $this->display(":$tplname");
    }


    public function navList() {
        $navcatname="页面";

        $where = array();
        $where['status'] = array('eq',1);
        $where['type']   = array('eq',2);

        $article = M("CmsArticle");
        $datas=$article->where($where)->select();
        $navrule=array(
            'id'=>'article_id',
            "action"=> 'PcHome/OnePage/index',
            "param"=>array(
                "id"=>"article_id"
            ),
            "label"=>"title",
            'parentid'=>0
        );
        return x_get_all_nav_list($navcatname,$datas,$navrule);
    }
}